// ignore_for_file: overridden_fields

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';

///
///Author: YYF
///Date: 2022-02-06 16:45:11
///Description:
///

/// 第一次欢迎页面
class RouteWelcomeMiddleware extends GetMiddleware {
  // priority 数字小优先级高
  @override
  int? priority = 0;

  RouteWelcomeMiddleware({required this.priority});

  @override
  RouteSettings? redirect(String? route) {
    if (ConfigStore.to.isFirstOpen == true) {
      return null;
    } else if (UserStore.to.hasToken == true) {
      return const RouteSettings(name: AppRoutes.INITIAL);
    } else {
      return const RouteSettings(name: AppRoutes.LOGIN);
    }
  }
}
